<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp" %>
<script type="text/javascript">

	$(function(){
	//关闭按钮
		$("#join_pic_topic_dialog_close").click(function(){
			$("#join_pic_topic_dialog").hide();
			hideMask();
		});
	//提交按钮
		$("#join_topic_submit").click(function(){
			var pictorialTopic = "";
			var i = 0;
			$("#joined_topic a").each(function(){
				var topicId = $(this).attr("topicId");
				if(i!=0){
					pictorialTopic+=",";
				}
				pictorialTopic+=topicId;
				i++;
			});
			
			$.post("joinTopicSave.htm",{
				identifier:'${pictorialId}',
				pictorialTopic : pictorialTopic
			},function(data){
				if(data == 'success'){
					$("#join_pic_topic_dialog").hide();
					hideMask();
					alert("加入主题成功");
				}else{
					$("#join_pic_topic_dialog").hide();
					hideMask();
					alert("加入主题失败");
				}
				
			});
		});	
		
	});
	
	
	function removeTopic(topicId){
		$("#join_topic_list_"+topicId).show().attr("class","redColor").unbind("click").attr("onclick","").bind("click",function(){
			joinTopicList(topicId);
		});
		$("#joined_topic_"+topicId).remove();
	}
	function joinTopicList(topicId){
		if($("#joined_topic a").size() > 0){
			alert("只能加入一个主题！");
		}else{
			var topicName = $("#join_topic_list_"+topicId).attr("topicName");
			var html = $('<a href="javascript:;" topicId="'+topicId+'" id="joined_topic_'+topicId+'" onclick=removeTopic("'+topicId+'") class="redColor">'+topicName+'<img src="imgs/tcZTPic01.png"></a>');
			$("#joined_topic").append(html);
			
			$("#join_topic_list_"+topicId).attr("class","clickStyle_y").attr("onclick","").unbind("click").hide();
		}
		
	}
	
/*
	function removeTopic(topicId){
		$("#join_topic_list_"+topicId).show().attr("class","redColor").unbind("click").attr("onclick","").bind("click",function(){
			joinTopicList(topicId);
		});
		$("#joined_topic_"+topicId).remove();
	}
	function joinTopicList(topicId){
		var topicName = $("#join_topic_list_"+topicId).attr("topicName");
		var html = $('<a href="javascript:;" topicId="'+topicId+'" id="joined_topic_'+topicId+'" onclick=removeTopic("'+topicId+'") class="redColor">'+topicName+'<img src="imgs/tcZTPic01.png"></a>');
		
	//	alert($("#joined_topic a").attr("topicid"));
		var oldTopicId = $("#joined_topic a").attr("topicid");
		removeTopic(oldTopicId);
		$("#joined_topic").append(html);
		
		$("#join_topic_list_"+oldTopicId).show();
		$("#join_topic_list_"+topicId).hide();
		
	}
*/
</script>	

<div class="loginBGTop_Send_y"></div>
   <div class="loginContent_Send_y">
   	<div class="middleContentTop_Send_y">
       	<div class="loginHeadInfo_Send_y">选择主题</div>
           <div class="loginHeadClosed_Send_y"><a href="javascript:;" id="join_pic_topic_dialog_close"><img src="imgs/login-close.png" alt="关闭"></a></div>       
       </div>
       
       <div class="sendMessageFrameSet">
       	   <div class="joinZT_y">
           	<span class="joinTitle_y fontColor333">我已加入的主题</span>
               <p class="joinContent_y clearfix" id="joined_topic">
               	   <c:forEach items="${ptListed}" var="pted">
	               		<c:choose>
	               	   		<c:when test="${pted.type=='01'}">
	               	   			<a href="javascript:;" topicId="${pted.identifier}" id="joined_topic_${pted.identifier}" onclick="removeTopic('${pted.identifier}');" class="redColor"><c:out value="${pted.name}"/><img src="imgs/tcZTPic01.png"></a>
	               	   		</c:when>
	               	   		<c:when test="${pted.type=='02'}">
	               	   			<a href="javascript:;" topicId="${pted.identifier}" id="joined_topic_${pted.identifier}" class="redColor" style="padding-right: 7px;"><c:out value="${pted.name}"/></a>
	               	   		</c:when>
	               	   </c:choose>
	               		
	               </c:forEach>
               </p>
           </div>
           <div class="joinZT_y">
           	<span class="joinTitle_y fontColor333">选择加入主题</span>
               <p class="choiceJoinContent_y clearfix">
               	<c:forEach items="${ptListedNoLock}" var="pt">
               			<c:choose>
               				<%--<c:when test="${pt.isLock && pt.type=='01'}">
               					<a href="javascript:;" id="join_topic_list_${pt.identifier}"  class="clickStyle_y"  topicName='<c:out value="${pt.name}" />'>+ <c:out value="${pt.name}" /></a>
               				</c:when>
               				--%>
               				<c:when test="${pt.type=='01'}">
               					<a <c:if test="${pt.isLock}">style="display:none;"</c:if> href="javascript:;" id="join_topic_list_${pt.identifier}" onclick="joinTopicList('${pt.identifier}');" class="redColor"  topicName='<c:out value="${pt.name}" />'>+ <c:out value="${pt.name}" /></a>
               				</c:when>
               			</c:choose>
               		
               	</c:forEach>
               </p>
           </div>
      	
      	<p class="choiceJoinIn_y"><a href="javascript:;" title="" id="join_topic_submit"><img src="imgs/tcZTPic02.png"></a></p>
       </div>
       
 </div>
<div class="sendBGBottom_y"></div>
